package com.hongyuan.sellfitness.ui.person.activity;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.CustomActivity;
import com.hongyuan.sellfitness.base.CustomViewModel;
import com.hongyuan.sellfitness.databinding.ActivityVersionInforBinding;
import com.hongyuan.sellfitness.ui.main.activity.WebActivity;

import me.tatarka.bindingcollectionadapter2.BR;

public class VersionInforActivity extends CustomActivity<ActivityVersionInforBinding, CustomViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_version_infor;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initView() {
        super.initView();

        binding.comBack.setOnClickListener(view -> finish());

        //获取版本信息
        PackageManager manager = getPackageManager();
        String name = null;
        try {
            PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
            name = info.versionName;
            binding.banBen.setText(name+"版本");
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        binding.goAgreement.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("url","https://fit.1667799.com/html/xy.html");
                bundle.putString("title","用户协议");
                startActivity(WebActivity.class,bundle);
            }
        });
        binding.goYinSi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("url","https://fit.1667799.com/html/ys.html");
                bundle.putString("title","用户协议");
                startActivity(WebActivity.class,bundle);
            }
        });
    }

}
